Crate dos_uid_derive

source ·
Expand description

§UID

A derive macro that implements the UniqueIdentifier trait.

§Examples

Setting the data type and port # to the default values: Vec<f64> and 50_000u32, respectively:

use interface::UID;

#[derive(UID)]
enum Tag {}

The data type and port # are set with:

use interface::UID;

struct Q<T>(std::marker::PhantomData<T>);

enum ID {}

#[derive(UID)]
#[uid(data = Q<ID>, port = 9999)]
enum TU {}

An alias is a type that implements the Read, Write or Size trait of another type that implements the same traits for the same client:

use interface::{UID, Data, Read, Size, Update, Write};

struct Client {}
impl Update for Client {}
impl Write<TU> for Client {
    fn write(&mut self) -> Option<Data<TU>> {
        None
    }
}
impl Read<TU> for Client {
    fn read(&mut self, _data: Data<TU>) {}
}
impl Size<TU> for Client {
    fn len(&self) -> usize {
        1234
    }
}

#[derive(UID)]
#[alias(name = TU, client = Client, traits = Write, Read, Size)]
enum TUT {}

Derive Macros§